<%  
	var Command=Class.create();
		Command.prototype=
		{
			initialize:function($options)
			{
				this.object=Server.CreateObject('ADODB.Command');

				if(arguments.length!=0)
				{
					$options=($options||{});
					
					/* 声明属性 */
					this.result=null;
					this.activeconnection=$options.activeconnection;
					this.commandtext=$options.commandtext;				
					this.name=$options.name;
					this.commandtype=($options.commandtype||8);								
					this.commandtimeout=($options.commandtimeout||30);
					this.prepared=($options.prepared||false);
					this.isexecute=($options.isexecute==false)? false:true;	
				
					/* 构造对象 */
					try
					{	
						if(this.name!=undefined)
							this.object.Name=this.name;
																				
						if(this.commandtext!=undefined) 
							this.object.commandtext=this.commandtext;	
							
						this.object.commandtimeout=this.commandtimeout;
						this.object.commandtype=this.commandtype;
						this.object.Prepared=this.prepared;						
					
						if(this.activeconnection==undefined&&typeof($System)!='undefined')
						{
							this.activeconnection=(new Connection($System.connection)).object;
						}	
						if(this.activeconnection!=undefined) 
						{
							this.object.activeconnection=this.activeconnection;	
						}				
					
						if(this.isexecute==true)
						{		
							if(this.object.activeconnection==undefined) 
								throw 'Connection error';	
								
							if(this.object.commandtext=='')
								throw 'Commandtext error';																	

							this.result=this.object.Execute();					
						}						
					}
					catch(e)
					{
						if(e=='Connection error')
							throw new Error(cusErrors_0020_ADO$Command);
						else if(e=='Commandtext error')						
							throw new Error(cusErrors_0021_ADO$Command);
						else 
						{
							if(e!=cusFrameworkDo$Break&&Object.varType(e)!='string')							
								throw e;
							else
								throw new Error(e);
						}
					}
				}
			},
			get:function($property)
			{
				if(($property in this.object)==false)		
					throw new Error(cusErrors_0099_ADO$Global);
					
				$property=($property.toLowerCase());
				if($property in this.object) this[$property]=this.object[$property];				
				return this.object[$property];
			},			
			set:function($property,$value)
			{
				if(($property in this.object)==false)
					throw new Error(cusErrors_0099_ADO$Global);
					
				$property=($property.toLowerCase());				
				this[$property]=$value;
				return this.object[$property]=$value;
			},	
			parameters:function()
			{
				return this.object.Parameters;
			},
			properties:function()
			{
				return this.object.Properties;		
			},
			cancel:function()
			{
				this.object.Cancel();
			},
			execute:function($recordsAffected,$parameters,$options)
			{
				this.result=this.object.Execute($recordsAffected,($parameters||null),($options||8));					
			},		
			createParameter:function($name,$type,$direction,$size,$value)
			{
				return this.object.CreateParameter($name,$type,$direction,$size,$value);
			},
			close:function()
			{
				try
				{
					if(this.result!=null) this.result=null;
					this.object=null;					
				}
				catch(e)
				{}
			}
		};		
%>